﻿

using Maticsoft.BLL;
using Maticsoft.Model;
using System;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class WebPage_SheZhi_YeMian : SystemBBasePage
{
   
    private Maticsoft.BLL.Page pages = new Maticsoft.BLL.Page();

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.div1.Visible = true;
        foreach (Maticsoft.Model.Page page in this.pages.GetModelList("Id='" + this.DropDownList1.SelectedItem.Value + "'"))
        {
            this.pageContent.Value = page.Value;
        }
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        this.HeaderControl1.Select = "shezhi";
        if (!base.IsPostBack)
        {
            this.setPage();
        }
    }

    private void setPage()
    {
        this.DropDownList1.Items.Clear();
        this.div1.Visible = false;
        ListItem item = new ListItem();
        item.Text = "-----";
        item.Value = "-1";
        this.DropDownList1.Items.Add(item);
        Maticsoft.BLL.System system = new Maticsoft.BLL.System();
        Maticsoft.Model.System model = new Maticsoft.Model.System();
        foreach (Maticsoft.Model.Page page in this.pages.GetModelList(""))
        {
            model = system.GetModel(1);
            ListItem item2 = new ListItem();
            if (page.Id == "help_tour")
            {
                if (model != null)
                {
                    item2.Text = "玩转" + model.abbreviation;
                }
                else
                {
                    item2.Text = "玩转";
                }
                item2.Value = page.Id;
            }
            if (page.Id == "help_faqs")
            {
                item2.Value = page.Id;
                item2.Text = "常见问题";
            }
            if (page.Id == "help_asdht")
            {
                if (model != null)
                {
                    item2.Text = "什么是" + model.abbreviation;
                }
                else
                {
                    item2.Text = "什么是";
                }
                item2.Value = page.Id;
            }
            if (page.Id == "help_api")
            {
                item2.Value = page.Id;
                item2.Text = "开发API";
            }
            if (page.Id == "about_contact")
            {
                item2.Value = page.Id;
                item2.Text = "联系方式";
            }
            if (page.Id == "about_job")
            {
                item2.Value = page.Id;
                item2.Text = "工作机会";
            }
            if (page.Id == "about_us")
            {
                if (model != null)
                {
                    item2.Text = "关于" + model.abbreviation;
                }
                else
                {
                    item2.Text = "关于";
                }
                item2.Value = page.Id;
            }
            if (page.Id == "about_terms")
            {
                item2.Value = page.Id;
                item2.Text = "用户协议";
            }
            if (page.Id == "about_privacy")
            {
                item2.Value = page.Id;
                item2.Text = "隐私声明";
            }
            this.DropDownList1.Items.Add(item2);
        }
        this.DropDownList1.DataBind();
    }

    protected void submit_Click1(object sender, EventArgs e)
    {
        if ((this.DropDownList1.SelectedItem != null) && this.div1.Visible)
        {
            this.updatePage(this.DropDownList1.SelectedItem.Value);
        }
        this.setPage();
    }

    private void updatePage(string id)
    {
        if (id == "-1")
        {
            this.SetError("您没有选择项，请选择!");
        }
        else
        {
            Maticsoft.Model.Page model = new Maticsoft.Model.Page();
            model.Id = this.DropDownList1.SelectedItem.Value;
            model.Value = this.pageContent.Value;
            this.pages.Update(model);
            base.SetSuccess("设置成功");
        }
    }
}


